package org.linlinjava.litemall.db.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.IntegerTypeHandler;
import org.linlinjava.litemall.db.handler.IntegerArrayJsonTypeHandler;
import org.linlinjava.litemall.db.mybatis.JsonIntegerArrayTypeHandler;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@TableName(value = "lumiere_coupon_strategy",autoResultMap = true)
@AllArgsConstructor
@NoArgsConstructor
public class LumiereCouponStrategy {

    @JsonSerialize(using = ToStringSerializer.class)
    @TableId(type = IdType.AUTO)
    private Long id;

    @JsonSerialize(using = ToStringSerializer.class)
    private Long couponId;

    private String name;

    private Integer couponType;

    @TableField(typeHandler = JsonIntegerArrayTypeHandler.class)
    private Integer[] ranges;

    private Byte discountType;

    private BigDecimal discountRate;
    private BigDecimal discount;

    private BigDecimal min;

    private BigDecimal rechargeAmount;
    @TableField(typeHandler = JsonIntegerArrayTypeHandler.class)
    private Integer[] rechargeGift;
    private Short userLimit;
    private Integer total;
    /**
     * 使用限制
     */
    private Short useLimit;

    /**
     * 使用限制num
     */
    private Integer useLimitNum;

    private Boolean isShow;
    /**
     * 时间类型
     */
    private Short timeType;

    /**
     * 天
     */
    private Short days;

    /**
     * 开始时间
     */
    private LocalDateTime startTime;

    /**
     * 结束时间
     */
    private LocalDateTime endTime;

    private Short lossBearing;
    private String useInstruction;
    private Boolean status;
    @TableField(typeHandler = JsonIntegerArrayTypeHandler.class)
    private Integer[] levelMember;

    @TableField(typeHandler = JsonIntegerArrayTypeHandler.class)
    private Integer[] payMember;
    private Integer releasedQuantity;
    private Integer period;

    private Short goodsType;

    @TableField(typeHandler = IntegerArrayJsonTypeHandler.class)
    private Integer[] goodsValue;

    @TableField(typeHandler = IntegerArrayJsonTypeHandler.class)
    private Integer[] selectGoods;

    private Short areaLimit;

    @TableField(typeHandler = IntegerArrayJsonTypeHandler.class)
    private Integer[] regions;

    private LocalDateTime addTime;

    /**
     * 更新时间
     */
    private LocalDateTime updateTime;

    /**
     * 删除
     */
    @TableLogic
    private Boolean deleted;

    @TableField(exist = false)
    private String couponName;

    @TableField(exist = false)
    private String pictureUrl;

}
